package com.vmj.natives.java.lang;

import com.vmj.heap.VMObject;
import com.vmj.heap.StringPool;
import com.vmj.natives.NativeMethod;
import com.vmj.natives.Registry;
import com.vmj.rtda.Frame;

/**
 * Created by yangshoujun on 2017/9/16 下午7:58.
 */
public class String {

    public static final java.lang.String jlClass = "java/lang/String";

    public static void init() {
        Registry.register(jlClass, "intern", "()Ljava/lang/String;", new NativeMethod() {
            public void execute(Frame frame) {
                VMObject _this = frame.getLocalVars().getThis();
                VMObject strObj = StringPool.getStringObject(frame.getMethod().getClazz().getClassLoader(), _this.getRefString());
                frame.getOperandStack().pushRef(strObj);
            }
        });
    }
}
